package demo03;

/*
 * 如果一个成员变量使用了static关键字，那么这个变量不再属于对象自己，而是属于所在的类，即多个对象共享一份数据。
 */
public class Demo01StaticField {
    public static void main(String[] args) {
        Student one = new Student("土司鸡", 18);
        one.room = "101教室";
        System.out.println("姓名：" + one.getName()
                + "，年龄：" + one.getAge()
                + "，教室：" + one.room
                + "，学号：" + one.getId());
        Student two = new Student("粹花", 3);
        System.out.println("姓名：" + two.getName()
                + "，年龄：" + two.getAge()
                + "，教室：" + two.room
                + "，学号：" + two.getId());
        Student three = new Student();
        System.out.println("姓名：" + three.getName()
                + "，年龄：" + three.getAge()
                + "，教室：" + three.room
                + "，学号：" + three.getId()); // 学号：3
        Student four = new Student("老虎", 8);
        System.out.println("姓名：" + four.getName()
                + "，年龄：" + four.getAge()
                + "，教室：" + four.room
                + "，学号：" + four.getId());
    }
}
